home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / getofil.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  2KB  |  88 lines

  1. program GetOFil;
  2.  
  3. { Testprogram for the nwFile unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  4.  
  5. { Uses the following calls:
  6.  
  7.   GetConnectionsOpenFiles (nwServ)
  8.   MapDirEntryIdToPath     (nwFile)
  9.  
  10. }
  11.  
  12. uses nwMisc,nwConn,nwFile,nwServ;
  13.  
  14.  
  15. Var ConnNumber     : Byte;
  16.     LastRecordSeen : word;
  17.     NbrOfRecords   : word;
  18.     FileInfo       : TfileInfoRecList;
  19.     t              : Byte;
  20.     ExtPath,DosPath: string;
  21.     VolName        : string;
  22.  
  23.     errCode:Integer;
  24.     dHelp:byte;
  25.     INaddress:TinternetworkAddress;
  26.  
  27. begin
  28. dHelp:=0;
  29.  
  30. If (NOT CheckConsolePrivileges)
  31.  then dHelp:=4;
  32.  
  33. IF (ParamCount<>1)
  34.  then dHelp:=1;
  35.  
  36. if dHelp=0
  37.  then begin
  38.       Val(ParamStr(1),ConnNumber,errCode);
  39.       if (errCode<>0) then dHelp:=2;
  40.       end;
  41.  
  42. { determine whether connectionnumber is valid.
  43.   Remember: using invalid connectionnumbers in combination with the
  44.             GetConnection'sOpenFiles function may result in an Abend.. }
  45. if (dHelp=0) and (NOT GetInterNetAddress(connNumber,INaddress))
  46.  then dHelp:=3;
  47.  
  48. if dHelp>0
  49.  then begin
  50.       if (dHelp=2) or (dHelp=3)
  51.        then writeln('Error: invalid connection number specified.');
  52.       if dHelp=4
  53.        then writeln('!! You need console operator privileges to use this utility.');
  54.       writeln;
  55.       writeln('GETOFIL - Get connection''s open files.');
  56.       writeln;
  57.       writeln('Usage: GETOFIL <connection number>');
  58.       halt(1);
  59.       end;
  60.  
  61. LastRecordSeen:=0;
  62.  
  63. Writeln('Files currently held open by connection ',ConnNumber);
  64. REPEAT { iterate / "only" 28 files (max.) returned per call }
  65.  IF GetConnectionsOpenFiles (ConnNumber, LastRecordSeen,
  66.                              NbrOfRecords ,FileInfo)
  67.    then begin
  68.         for t:=1 to NbrOfRecords
  69.          do with FileInfo[t]
  70.              do begin
  71.                 IF MapDirEntryIdToPath(VolNbr,ParentEntryID,NStype,
  72.                                        FileName)
  73.                  then begin
  74.                       NovPath2DosPath(ExtPath,DosPath);
  75.                       GetVolumeName(VolNbr,VolName);
  76.                       writeln(VolName,':',DosPath,'\',FileName)
  77.                       end
  78.                  else writeln('Error calling MapDirEntryIdToPath, err#',nwFile.result);
  79.                 end;
  80.         end
  81.    else begin
  82.         writeln('err: ',nwServ.result);
  83.         halt(1);
  84.         end;
  85. UNTIL LastRecordSeen=0;
  86.  
  87. end.
  88.